package conf

import (
	"gopkg.in/yaml.v3"
	"os"
)

type Config struct {
	Server StorageRoots `yaml:"server"`
}

type StorageRoots struct {
	Dir          string `yaml:"dir"`
	RabbitServer string `yaml:"rabbit"`
	Listen       string `yaml:"addr"`
}

func StorageRoot() *Config {

	file, err := os.Open("conf.yaml")
	defer file.Close()
	if err != nil {
		panic(err)
	}
	config := Config{}
	decoder := yaml.NewDecoder(file)
	err = decoder.Decode(&config)

	if err != nil {
		panic(err)
	}

	return &config
}
